//
//  PayResultVC.m
//  YYPHSpeedJump
//
//  Created by sujiang on 16/1/13.
//  Copyright © 2016年 sujiang. All rights reserved.
//

#import "PayResultVC.h"
#import "OrderFormViewController.h"

@interface PayResultVC ()

@end

@implementation PayResultVC
- (void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden = YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
   // NSLog(@"%@", self.dictionary);
    
    [self addSubViews];

    self.backBtn.layer.cornerRadius = 5;
    self.seeOrderList.layer.cornerRadius = 5;
    // Do any additional setup after loading the view from its nib.
}

- (void)addSubViews
{
    NSDictionary *dict = self.dictionary[@"data"];
    self.realName.text = [NSString stringWithFormat:@"收货人: %@", dict[@"real_name"]];
    self.orderLb.text = [NSString stringWithFormat:@"订单号: %@", dict[@"deal_id"]];
    self.phoneNum.text = [NSString stringWithFormat:@"联系电话: %@", dict[@"phone"]];
    self.addressLb.text = [NSString stringWithFormat:@"收货地址: %@", dict[@"address"]];
    if ([self.dictionary[@"code"]isEqualToString:@"200"]) {
        self.resultLb.text = @"支付成功!";
        self.statusImage.image = [UIImage imageNamed:@"duigou"];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"PAYSUCCESS" object:nil userInfo:nil];

    } else {
        self.statusImage.image = [UIImage imageNamed:@"shibai"];
        self.resultLb.text = @"支付失败!";
        self.reasonLb.text = self.dictionary[@"message"];
    }
}


- (IBAction)seeOrderList:(id)sender {
    OrderFormViewController *orderFormVC = [[OrderFormViewController alloc] init];
    [self.navigationController pushViewController:orderFormVC animated:YES];
    // orderFormVC.segment.selectedSegmentIndex = 1;
    if ([self.resultLb.text isEqualToString:@"支付成功"]) {
        orderFormVC.pushType = 1;
    }
}

- (IBAction)goBackToRoot:(id)sender {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
